package com.yicong.ants.ui.me;

import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.view.View;

import com.cchao.simplelib.ui.activity.BaseTitleBarActivity;
import com.yicong.ants.R;
import com.yicong.ants.databinding.ActivityPrivacyPrivilegeBinding;


/**
 * 隐私权限
 */
public class PrivacyPrivilegeActivity extends BaseTitleBarActivity<ActivityPrivacyPrivilegeBinding> implements View.OnClickListener {

    @Override
    protected int getLayout() {
        return R.layout.activity_privacy_privilege;
    }

    @Override
    protected void initEventAndData() {
        setTitleText("系统权限管理");
        mDataBind.setting.setOnClickListener(this);
    }

    @Override
    protected void onLoadData() {

    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.setting) {
            getAppDetailSettingIntent();
        }
    }

    private void getAppDetailSettingIntent() {
        Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (Build.VERSION.SDK_INT >= 9) {
            intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.setData(Uri.fromParts("package", getPackageName(), null));
        } else if (Build.VERSION.SDK_INT <= 8) {
            intent.setAction(Intent.ACTION_VIEW);
            intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
            intent.putExtra("com.android.settings.ApplicationPkgName", getPackageName());
        }
        startActivity(intent);
    }
}
